package com.jgraph.editor.persistence;

import java.util.Properties;

/**
 * This interface defines the contract for {@link JGraphPersistenceManager}
 * factory methods. Such a factor methods knows how to construct a persistence
 * manager of a given type. Each persistence manager supports one or more
 * file types (identified by their extensions).
 *
 * @param T The type of objects handled by the created persistence manager.
 *
 * @author svetoslavganov@mail.utexas.edu
 *
 */
public abstract class JGraphPersistenceManagerFactoryMethod<T> {

	private String[] mFileExtensions;

	private Properties mProperties;

	/**
	 * Constructs a new instance given the file types it supports.
	 *
	 * @param fileExtensions The supported file types.
	 * @param properties The {@link Properties} instance passed to the
	 *        {@link JGraphPersistenceManager} created by this factory method.
	 */
	public JGraphPersistenceManagerFactoryMethod(String[] fileExtensions,
			Properties propeties) {
        mFileExtensions = fileExtensions;
        mProperties = propeties;
	}

	/**
	 * Gets the supported file extensions.
	 *
	 * @return The file extensions.
	 */
	public String[] getFileExtensions() {
		return mFileExtensions;
	}

	/**
	 * Gets the properties instance passed to {@link JGraphPersistenceManager}
	 * created by this factory method.
	 *
	 * @return The properties.
	 */
	public Properties getProperties() {
	    return mProperties;	
	}

	/**
	 * Creates a new {@link JGraphPersistenceManager} instance for a given
	 * configuration.
	 *
	 * @param properties A {@link Properties} that carries configuration
	 *        information for the instance to be created.
	 * @return A new {@link JGraphPersistenceManager} instance.
	 */
	public abstract JGraphPersistenceManager<T> createPersistenceManager(
			Properties properties);
}
